'''
生成器方法：
__next__(): 调用生成器函数，返回生成器的下一个值
send(value):向每次生成器调用中传值 注意：第一次调用send(None)
'''

# def get():
#     i = 0
#     while i < 5:
#         temp = yield i # return i + 暂停
#         print('temp:',temp)
#         i += 1
#     return '没有更多数据了'
#
# g = get()
# print(next(g))
# print(next(g))
# print(next(g))

# print(g.send(None))
# n1 = g.send('hello')
# print('n1:',n1)
# n2 = g.send('world')
# print('n2:',n2)

def get():
    i = 0
    while i < 5:
        temp = yield i # return i + 暂停
        print('temp:',temp)
        for x in range(temp):
            print('--->',x)
        print('**************')
        i += 1
    return '没有更多数据了'

g = get()
print(g.send(None))
n1 = g.send(3)
print('n1:',n1)
n2 = g.send(5)
print('n2:',n2)
